<!DOCTYPE html>
<title>Test that removing valid "src" attribute doesn't trigger load of "source" elements.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video>
    <source></source>
</video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");

    video.onloadedmetadata = t.step_func(function() {
        testSrc();
        video.removeAttribute("src");
        video.onloadedmetadata = t.unreached_func();

        setTimeout(t.step_func_done(function() {
            testSrc();
        }), 100) ;
    });

    function testSrc() {
        var url = video.currentSrc;
        assert_equals(url.substr(url.lastIndexOf("/media/")+7), mediaFile);
        assert_false(isNaN(video.duration));
    }

    document.querySelector("source").src = "content/counting.ogv";
    var mediaFile = "content/test.ogv";
    video.src = mediaFile;
});
</script>